<template>
  <div style="height: 100%; width: 100%; position: relative;" ref="maindev">
      <div class="pagetop">
          <div style="width:100%;">
              <table style="width: 100%; font-size: 12px;white-space: nowrap;" border="0">
                  <col style="width: 5%;" />
                  <col style="width: 11%;" />
                  <col style="width: 1%;" />
                  <col style="width: 11%;" />
                  <col style="width: 5%;" />
                  <col style="width: 9%;" />
                  <col style="width: 5%;" />
                  <col style="width: 8%;" />
                  <col style="width: 5%;" />
                  <col style="width: 8%;" />
                  <col style="width: 6%;" />
                  <col style="width: 9%;" />
                  <col style="width: 6%;" />
                  <col style="width: 9%;" />
                  <tr>
                      <td align="right">
                          <el-dropdown @command="handleCommand" style="font-size:12px">
                              <u class="el-dropdown-link">
                                  {{datename}}
                              </u>
                              <el-dropdown-menu slot="dropdown">
                                  <el-dropdown-item command="接收日期">
                                      <font font-size="12px">接收日期</font>
                                  </el-dropdown-item>
                                  <el-dropdown-item command="报告日期">
                                      <font font-size="12px">报告日期</font>
                                  </el-dropdown-item>
                                  <el-dropdown-item command="工作组签收日期">
                                      <font font-size="12px">工作组签收日期</font>
                                  </el-dropdown-item>
                              </el-dropdown-menu>
                          </el-dropdown>
                      </td>
                      <td>
                          <el-date-picker v-model="searchobj.strdate" :clearable="false" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
                      </td>
                      <td>至</td>
                      <td>
                          <el-date-picker v-model="searchobj.enddate" type="date" :clearable="false" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;"> </el-date-picker>
                      </td>
                      <td align="right">病人类型</td>
                      <td>
                          <el-select v-model="searchobj.pattype" filterable clearable @dblclick.native="popMultipleChk(pattype, 'pattype', pattypeOption, '病人类型选择')" ref="refpattype" @keyup.enter.native="selectBlur('pattype','refpattype',pattypeOption)" style="width:100%">
                              <el-option v-for="(item, index) in pattypeOption" :value="item.data" :label="item.display" :key="index"> <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">检验组别</td>
                      <td>
                          <el-select v-model="searchobj.labgroupid" style="width: 100%;" filterable clearable ref="reflabgroupid" @keyup.enter.native="selectBlur('labgroupid','reflabgroupid',labgroupOption)">
                              <el-option v-for="(item, index) in labgroupOption" :key="index" :label="item.display" :value="item.data">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">申请科室</td>
                      <td>
                          <el-select v-model="searchobj.reqdeptno" @dblclick.native="popMultipleChk(searchobj.reqdeptno,'reqdeptno',deptOption,'申请科室选择')" filterable clearable>
                              <el-option v-for="(item,index) in deptOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">急诊标志</td>
                      <el-select v-model="searchobj.emerflag" clearable filterable style="width:100%">
                          <el-option label="急诊" value="1" key="1"></el-option>
                          <el-option label="常规" value="0" key="0"></el-option>
                      </el-select>
                      <td align="right">分单类别</td>
                      <td>
                          <el-select v-model="searchobj.req_groupid" @dblclick.native="popMultipleChk(searchobj.req_groupid, 'req_groupid', reqgroupOption, '请选择分单类别')" ref="refreq_groupid" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('req_groupid','refreq_groupid',reqgroupOption)">
                              <el-option v-for="(item, index) in reqgroupOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <!-- <td align="right" colspan="6" rowspan="2">
                          <table style="width:100%;" border="0" class="chktable">
                              <tr>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_pat_typecode" @change="chkevent($event,'rp_pat_typecode','病人类型')"><span style="font-size:12px;">病人类型</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_req_deptno" @change="chkevent($event,'rp_req_deptno','科室')"><span style="font-size:12px;">科室</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_req_groupid" @change="chkevent($event,'rp_req_groupid','分单类别')"><span style="font-size:12px;">分单类别</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_sample_items" @change="chkevent($event,'rp_sample_items','申请项目')"><span style="font-size:12px;">申请项目</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_labgroupname" @change="chkevent($event,'rp_labgroupname','检验组别')"><span style="font-size:12px;">检验组别</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_specimen_code" @change="chkevent($event,'rp_specimen_code','标本')"><span style="font-size:12px;">标本</span></el-checkbox>
                                  </td>
                              </tr>
                              <tr>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_emer_flag" @change="chkevent($event,'rp_emer_flag','急诊标志')"><span style="font-size:12px;">急诊标志</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_sampleyear" @change="chkevent($event,'rp_sampleyear','年')"><span style="font-size:12px;">年</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_samplemonth" @change="chkevent($event,'rp_samplemonth','月')"><span style="font-size:12px;">月</span></el-checkbox>
                                  </td>
                                  <td>
                                      <el-checkbox v-model="chklist.rp_sampleday" @change="chkevent($event,'rp_sampleday','日')"><span style="font-size:12px;">日</span></el-checkbox>
                                  </td>
                              </tr>
                          </table>
                      </td> -->
                  </tr>
                  <tr>
                      <td align="right">报告单元</td>
                      <td colspan="3">
                          <el-select v-model="searchobj.rptunitid" @dblclick.native="popMultipleChk(searchobj.rptunitid, 'rptunitid', rptunitOption, '请选择报告单元')" ref="refrptunitid" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('rptunitid','refrptunitid',rptunitOption)">
                              <el-option v-for="(item, index) in rptunitOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">分位数基准</td>
                      <td>
                          <el-input type="number" :max="99" :min="1" v-model="searchobj.median" style="width:70px" @input="clearTb"></el-input>%
                          &nbsp;&nbsp;&nbsp;&nbsp;基准2
                          <el-input type="number" :max="99" :min="1" v-model="searchobj.median2" style="width:70px" @input="clearTb"></el-input>%
                      </td>
                      <td align="right">基准时间</td>
                      <td>
                          <el-autocomplete class="inline-input" v-model="searchobj.tatminutes" :fetch-suggestions="querySearch" placeholder="" clearable ref="reftatminutes"></el-autocomplete>
                      </td>
                      <td colspan="2" align="left">
                          <el-checkbox true-label="1" false-label="0" v-model="searchobj.onlyouttime">仅统计超出基准时间</el-checkbox>
                      </td>
                      <td align="left" colspan="2">大于<el-input v-model="searchobj.outminutes" style="width:50px"></el-input>分钟不统计</td>
                      <td align="right" style="width:50px">查询模版</td>
                      <td>
                          <el-select v-model="querymod" placeholder="" @change="querymodChange($event)" clearable filterable style="width:110px">
                              <el-option v-for="(item,index) in querymodOption" :key="index" :value="item.value" :label="item.label"></el-option>
                          </el-select>
                          <el-button class="top-btn" @click.native="btnSavequerymod">保存</el-button>
                          <el-button class="top-btn" @click.native="btnDelquerymod">删除</el-button>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">申请项目</td>
                      <td colspan="3">
                          <el-select v-model="searchobj.reqitemcode" @dblclick.native="filterreqitem()" ref="refreqitemcode" filterable clearable style="width:100%" @keyup.enter.native="selectBlur('reqitemcode','refreqitemcode',reqitemOption)">
                              <el-option v-for="(item, index) in reqitemOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">统计类型</td>
                      <td>
                          <el-select v-model="searchobj.tattype" filterable ref="reftattype" @keyup.enter.native="selectBlur('tattype','reftattype',stattypeOption)" style="width:100%">
                              <el-option v-for="(item, index) in stattypeOption" :key="index" :value="item.data" :label="item.display">
                                  <span style="float: left">{{ item.display }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.data }}</span>
                              </el-option>
                          </el-select>
                      </td>

                      <td align="right" colspan="5">
                          <table style="width: 100%; font-size: 12px; white-space: nowrap;" border="0">
                              <tr>
                                  <td>
                                      <el-select v-model="searchobj.timetype" :clearable="false" ref="reftimetype" style="width:100%">
                                          <el-option value="recieve" label="接收时间"></el-option>
                                          <el-option value="report" label="报告时间"></el-option>
                                          <el-option value="recieve1" label="签收时间"></el-option>
                                      </el-select>
                                  </td>
                                  <td>
                                      <el-time-picker v-model="searchobj.starttime" :clearable="true" placeholder="选择时间" style="width: 100%;" value-format="HH:mm:ss"></el-time-picker>
                                  </td>
                                  <td>至</td>
                                  <td>
                                      <el-time-picker v-model="searchobj.endtime" :clearable="true" placeholder="选择时间" style="width: 100%;" value-format="HH:mm:ss"></el-time-picker>
                                  </td>
                                  <td>
                                      <el-checkbox true-label="1" false-label="0" v-model="searchobj.iseliminate">剔除</el-checkbox>
                                  </td>
                              </tr>
                          </table>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">统计项目</td>
                      <td colspan="3">
                          <div v-if="infoitem==''" @click="Btncountitem">
                              <span style="color:red;cursor:pointer;font-size:15px">点击该位置选择统计项目</span>
                          </div>
                          <div v-else>
                              <div @click="Btncountitem" style="width:100%;cursor:pointer;color:#409EFF"><u>{{infoitem}}</u></div>
                              <el-input v-model="infocode" readonly v-show="false"></el-input>
                          </div>
                      </td>
                      <td colspan='4' align="center" v-show="false">
                          <el-input v-model="searchobj.median" style="width:70px"></el-input>%分位数<el-input v-model="searchobj.median2" style="width:70px"></el-input>%分位数2
                      </td>

                      <td colspan="10" align="right">
                          <div>
                              <el-button @click.native="BtnQuery" v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
                              <!-- <el-button @click.native="BtnSort" icon="el-icon-sort">排序</el-button> -->
                              <el-button @click.native="BtnClear" icon="el-icon-close">清除</el-button>
                              <el-button @click.native="BtnExport" icon="el-icon-download">导出</el-button>
                              <!-- <el-button @click.native="BtnPrint(1)" icon="el-icon-printer">打印</el-button>
                              <el-button v-if="rptStyleSettingState" @click.native="BtnPrint(2)" class="el-icon-edit-outline">打印样式设计</el-button> -->
                          </div>
                      </td>
                  </tr>
              </table>
          </div>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <vxe-table :data.sync="tableData" :loading="loading" :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="xTable" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{ animat: false }" header-align="center" show-footer :footer-method="footerMethod" :footer-cell-class-name="footerCellClassName" :key="xTableKey" class="mytable-style" @cell-dblclick="rCellDblClick">
                  <vxe-table-column :field="items.field" :key="items.field" :title="items.title" sortable v-for="items in tableColumn" :width="items.width" :formatter="formatFun" :align="items.align" header-align="center">
                  </vxe-table-column>
                  <vxe-table-column field="samplecnt" sortable title="参与统计人次" width="90" show-overflow align="right"></vxe-table-column>
                  <vxe-table-column field="untatcnt" sortable title="不参与统计人次" width="100" show-overflow header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="minminutes" sortable title="最短时间" width="80" show-overflow header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="maxminutes" sortable title="最长时间" width="80" show-overflow align="right" header-align="center"></vxe-table-column>
                  <vxe-table-column field="avgminutes" sortable title="平均时间" width="80" show-overflow header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="median" sortable title="中位数" width="70" show-overflow header-align="center" align="right">
                      <template v-slot:header="{column}">
                          <span>{{searchobj.median}}%分位数</span>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="median2" sortable title="中位数2" width="80" show-overflow header-align="center" align="right"> <template v-slot:header="{column}">
                          <span>{{searchobj.median2}}%分位数</span>
                      </template></vxe-table-column>
                  <vxe-table-column field="tatminutes" sortable title="基准时间" width="70" show-overflow header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="unquailcnt" sortable title="不合格" width="70" show-overflow header-align="center" align="right"> <template v-slot="{row}">
                          <div style="color:blue;cursor:pointer"><u>{{row.unquailcnt}}</u></div>
                      </template></vxe-table-column>
                  <vxe-table-column field="quailcnt" sortable title="合格" width="70" show-overflow header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="passrate" sortable title="合格率%" width="70" show-overflow header-align="center" align="right" :formatter="formatFun"></vxe-table-column>
              </vxe-table>
          </div>
      </div>

      <!--多选弹窗--->
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
      <el-dialog width="1100px" title="不合格标本信息查看" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="bunquaildlg" :destroy-on-close="true">
          <div style="height: 35px;text-align:right;padding-right:10px;">
              <el-button @click="ExportResult()" v-has="'PEXPORT'" icon="el-icon-download">导出</el-button>
          </div>
          <div style="height: 500px; width: 100%">
              <div style="height: 100%">
                  <vxe-table ref="reqtable" :data.sync="unquaildata" :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow resizable show-overflow size="mini" show-header-overflow :optimization="{ animat: false }" header-align="center">
                      <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                      <vxe-table-column field="req_groupna" sortable title="分单类别" width="100" show-overflow align="center"></vxe-table-column>
                      <vxe-table-column field="req_deptno" sortable title="申请科室" width="100" show-overflow align="center" :formatter="formatFun"></vxe-table-column>
                      <vxe-table-column field="pat" sortable title="病人信息" align="center" width="180" show-overflow></vxe-table-column>
                      <vxe-table-column field="barcode" sortable title="条形码" align="center" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="sample_items" sortable title="申请项目(描述)" width="300" show-overflow></vxe-table-column>
                      <vxe-table-column field="tat_create_sampled" title="创建-采样" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_req_sampled" title="申请-采样" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_sampled_recieve" title="采样-接收" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="tat_recieve_report" title="接收-报告" align="center" width="80px"></vxe-table-column>
                      <vxe-table-column field="create_dt" align="center" sortable title="创建时间" width="120px" show-overflow></vxe-table-column>
                      <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="recieve_dt" title="接收时间" width="120px" align="center"></vxe-table-column>
                      <vxe-table-column field="test_dt" title="上机时间" align="center" width="120px"></vxe-table-column>
                      <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="send_dt" align="center" sortable title="送出时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="recieve1_dt" title="工作组接收时间" width="100px"></vxe-table-column>
                      <vxe-table-column field="report_dt" title="报告时间" width="120"></vxe-table-column>
                      <vxe-table-column field="sampled_user" title="采样人" width="100"></vxe-table-column>
                      <vxe-table-column field="report_username" title="检验者" width="100"></vxe-table-column>
                      <vxe-table-column field="rechk_username" title="审核者" width="100"></vxe-table-column>
                  </vxe-table>
              </div>
          </div>
      </el-dialog>

      <el-dialog title="统计项目" :visible.sync="dialogcountItem" width="1000px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false">

          <div style="width:100%;height:400px;margin-top:5px">
              <div style="width:70%;height:100%;float:left;overflow:auto;border:1px solid #ccc;">
                  <div id='left_nav' class="left_nav">
                      <div @click="showseq=1" :class="showseq == 1 ? 'active' : ''" ref="left1">
                          1 申请信息
                      </div>
                      <div @click="showseq=2" :class="showseq == 2 ? 'active' : ''" ref="left2">
                          2 送检信息
                      </div>
                      <div @click="showseq=3" :class="showseq == 3 ? 'active' : ''" ref="left3">
                          3 检验信息
                      </div>
                      <div @click="showseq=4" :class="showseq == 4 ? 'active' : ''" ref="left4">
                          4 病人信息
                      </div>
                      <div @click="showseq=5" :class="showseq == 5 ? 'active' : ''" ref="left5">
                          5 检验日期
                      </div>
                  </div>
                  <div id='right_nav' class="right_nav">
                      <table class="table1style" style="width:100%;padding:10px">
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请类别','rp_reqtype')" v-model="rp_reqtype">申请类别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'标本类型','rp_specimen_code')" v-model="rp_specimen_code">标本类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请项目代码','rp_req_itemcode')" v-model="rp_req_itemcode">申请项目</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'分单类别','rp_req_groupid')" v-model="rp_req_groupid">分单类别</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'申请日期','rp_req_dt')" v-model="rp_req_dt">申请日期</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'单价','rp_item_price')" v-model="rp_item_price">单价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'计价','rp_charge_flag')" v-model="rp_charge_flag">计价</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'销售','rp_saleman')" v-model="rp_saleman">销售</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'采样用户','rp_sampled_username')" v-model="rp_sampled_username">采样用户</el-checkbox>
                              </td>
                          </tr>
                          <!-- <tr v-show="showseq==1">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[0],'chkhisrefcol1')" v-model="chkhisrefcol1">{{hisrefcodelist[0]}}</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[1],'chkhisrefcol2')" v-model="chkhisrefcol2">{{hisrefcodelist[1]}}</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,hisrefcodelist[2],'chkhisrefcol3')" v-model="chkhisrefcol3">{{hisrefcodelist[2]}}</el-checkbox>
                              </td>
                          </tr> -->
                          <tr v-show="showseq==2">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医院','rp_hospitalname')" v-model="rp_hospitalname">送检医院</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检科室','rp_deptname')" v-model="rp_deptname">送检科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病区','rp_wardname')" v-model="rp_wardname">所在病区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'送检医生','rp_doctorname')" v-model="rp_doctorname" v-has="'PQREQDOC'">送检医生</el-checkbox>
                              </td>
                              <!--<td>
                                  <el-checkbox @change="chkcountitem($event,'送检目的','chksendreason')" v-model="chksendreason">执行科室</el-checkbox>
                              </td> -->
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验院区','rp_labhospitalname')" v-model="rp_labhospitalname">检验院区</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验科室','rp_labdeptname')" v-model="rp_labdeptname">检验科室</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'检验组别','rp_labgroupname')" v-model="rp_labgroupname">检验组别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'报告单元','rp_rptunitname')" v-model="rp_rptunitname">报告单元</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==3">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'审核医生','rp_rechk_username')" v-model="rp_rechk_username">审核医生</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'性别','rp_pat_sexname')" v-model="rp_pat_sexname">性别</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人类型','rp_pat_typecode')" v-model="rp_pat_typecode">病人类型</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人','rp_pat')" v-model="rp_pat">病人</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断','rp_pat_diag')" v-model="rp_pat_diag">诊断</el-checkbox>
                              </td>

                          </tr>
                          <tr v-show="showseq==4">
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'诊断ICD','rp_pat_diag_icd')" v-model="rp_pat_diag_icd">诊断ICD</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人ID','rp_pat_id')" v-model="rp_pat_id">病人ID</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'病人号','rp_pat_no')" v-model="rp_pat_no">病人号</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'床位','rp_req_bedno')" v-model="rp_req_bedno">床位</el-checkbox>
                              </td>
                          </tr>
                          <tr v-show="showseq==5">

                              <td>
                                  <el-checkbox @change="chkcountitem($event,'年','rp_sampleyear')" v-model="rp_sampleyear">年</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'月','rp_samplemonth')" v-model="rp_samplemonth">月</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'日','rp_sampleday')" v-model="rp_sampleday">日</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox @change="chkcountitem($event,'急诊标志','rp_emer_flag')" v-model="rp_emer_flag">急诊标志</el-checkbox>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
              <div style="width:29%;height:100%;float:left;margin-left:5px;overflow:auto;">
                  <vxe-table show-overflow ref="xTable2" height="auto" :data.sync="staticitemData" @current-change="dialogItemChange" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                      <vxe-table-column type="index" title="NO." width="50"></vxe-table-column>
                      <vxe-table-column field="countitem" title="统计项目" width="160" sortable header-align="center"></vxe-table-column>
                      <vxe-table-column field="countcode" title="统计代码" width="160" sortable header-align="center"></vxe-table-column>
                  </vxe-table>
              </div>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button icon="el-icon-top" @click="SetFirst()">首位</el-button>
              <el-button icon="el-icon-top-right" @click="SetUp()">上移</el-button>
              <el-button icon="el-icon-bottom-right" @click="SetDown()">下移</el-button>
              <el-button icon="el-icon-bottom" @click="SetLast()">末位</el-button>
              <el-button type="primary" @click="dialogcountItemsave">确 定</el-button>
              <el-button @click="dialogcountItem = false">取 消</el-button>
          </span>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS652",
  data() {
      return {
          bunquaildlg: false,
          unquaildata: [],
          oReqitemOption: [],
          stattypeOption: [
              { display: "申请到采样", data: "QC" },
              { display: "采样到送出", data: "CS" },
              { display: "送出到接收", data: "SR" },
              { display: "采样到接收", data: "CR" },
              { display: "接收到报告", data: "RP" },
              { display: "申请到报告", data: "QP" },
              { display: "采样到报告", data: "CP" },
              { display: "申请到接收", data: "QR" },
              { display: "送出到送达", data: "SA" },
              { display: "送达到接收", data: "AR" },
              { display: "送达到报告", data: "AP" },
              { display: "工作组接收到报告", data: "R1P" },
              { display: "上机到报告", data: "TP" },
              { display: "接收到上机", data: "RT" },
              { display: "送达到上机 ", data: "AT" },
              { display: "接收到工作组接收", data: "RR1" },
              { display: "采样到上机", data: "CT" },
              { display: "采样到送达 ", data: "CA" },
          ],
          tatminutesOption: [
              { label: "10", value: "10" },
              { label: "20", value: "20" },
              { label: "30", value: "30" },
              { label: "60", value: "60" },
              { label: "120", value: "120" },
          ],
          dialogMultipleVisible: false,
          loading: false,
          option1: [],
          option2: [],
          rptStyleSettingState: false,
          rptunitname: "",
          infocode: "",
          infoitem: "",
          fieldname: "",
          tableData: [],
          chkcnt: 0,
          xTableKey: 0,
          multichktitle: "",
          datename: "接收日期",
          datetype: "recieve_dt",
          pattypeOption: [],
          deptOption: [],
          reqitemOption: [], //申请项目
          rptunitOption: [],
          labgroupOption: [],
          specimenOption: [],
          deptgroupOption: [], //deptcomb
          reqgroupOption: [],
          tableColumn: [],
          //以下为查询条件
          searchobj: {
              strdate: this.$pub.InitDateTime(),
              enddate: this.$pub.InitDateTime(),
              pattype: "",
              rptunitid: "",
              labgroupid: "",
              emerflag: "",
              median: "50",
              median2: "90",
              tatminutes: "",
              onlyouttime: "0",
              tattype: "RP",
              outminutes: "",
              reqdeptno: "",
              reqitemcode: "",
              req_groupid: "",
              starttime: "",
              endtime: "",
              timetype: "recieve",
              iseliminate: "0",
          },
          // chklist: {
          //     rp_pat_typecode: false,
          //     rp_req_deptno: false,
          //     rp_req_groupid: false,
          //     rp_sample_items: false,
          //     rp_labgroupname: false,
          //     rp_specimen_code: false,
          //     rp_emer_flag: false,
          //     rp_sampleyear: false,
          //     rp_samplemonth: false,
          //     rp_sampleday: false,
          // },
          //以下为排序数组
          sortArr: [],
          SortTableColumn: [
              // { title: "细菌名称", field: "cp_samplecnt" },
              // { title: "细菌次数", field: "cp_cnt" },
              // { title: "细菌金额", field: "cp_amt" },
              // { title: "药敏项次", field: "cp_rs" },
              // { title: "药敏金额", field: "cp_redocnt" },
              // { title: "合计金额", field: "cp_amt" },
          ],
          hisrefcodelist: [],
          dialogcountItem: false,
          currentindex: -1,
          staticitemData: [],
          infoitem: "",
          infocode: "",
          showseq: 1,
          dialogcountItem: false,

          rp_reqtype: false,
          rp_specimen_code: false,
          rp_req_itemcode: false,
          rp_req_itemname: false,
          rp_item_price: false,
          rp_charge_flag: false,
          rp_req_dt: false,
          rp_req_groupid: false,
          rp_saleman: false,
          rp_sampled_username: false,
          rp_hospitalname: false,
          rp_deptname: false,
          rp_wardname: false,
          rp_doctorname: false,
          rp_labhospitalname: false,
          rp_labdeptname: false,
          rp_labgroupname: false,
          rp_rptunitname: false,
          rp_rechk_username: false,
          rp_pat_sexname: false,
          rp_pat_typecode: false,
          rp_pat: false,
          rp_pat_diag: false,
          rp_pat_diag_icd: false,
          rp_pat_id: false,
          rp_pat_no: false,
          rp_req_bedno: false,
          rp_sampleyear: false,
          rp_samplemonth: false,
          rp_sampleday: false,
          rp_emer_flag: false,
          querymod: "",
          querymodOption: [],
          exportTableColLen: 0,
          selrow: {},
      };
  },
  created() {
      this.initOption();
      this.getOption();
      this.getLoginutype();
  },
  mounted() {},
  updated() {},
  methods: {
      clearTb() {
          this.tableData = [];
      },
      dialogItemChange({ row, rowIndex }) {
          this.currentindex = rowIndex;
      },
      chkcountitem(e, name, code) {
          let tablelist = this.$refs.xTable2.tableData;
          let ishave = tablelist.filter((m) => m.countcode == code);
          if (e) {
              if (tablelist.length <= 6) {
                  if (ishave.length == 0) {
                      this.$refs.xTable2.insert({ countitem: name, countcode: code }).then(({ row }) => {
                          this.$refs.xTable2.setCurrentRow(row).then(() => {
                              this.currentindex = this.$refs.xTable2.getRowIndex(this.$refs.xTable2.getCurrentRow());
                          });
                      });
                  }
              } else {
                  e = false;
                  this[code] = false;
                  this.$alert("您好，最多只能添加7条统计项目！", "提示", {
                      confirmButtonText: "确定",
                  });
              }
          } else {
              try {
                  if (ishave.length > 0) {
                      var rowindex = this.$refs.xTable2.getRowIndex(ishave[0]);
                      e = false;
                      this.$refs.xTable2.remove(ishave[0]);
                      let havedata = this.$refs.xTable2.tableData;
                      if (havedata.length > 0) {
                          if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                          let selectrow = havedata[rowindex];
                          this.$refs.xTable2.setCurrentRow(selectrow);
                      }
                  }
              } catch (e) {
                  console.log("error", e);
              }
          }
      },
      Btncountitem() {
          //重置所有选项
          this.resetStasticItem();
          this.dialogcountItem = true;
          //表格及checkbox重新赋值
          setTimeout(() => {
              this.$refs.xTable2.tableData = [];
              if (this.infoitem != "") {
                  let name = this.infoitem.split(",");
                  let code = this.infocode.split(",");
                  let datas = this.$refs.xTable2.tableData;
                  for (let i = 0; i < name.length; i++) {
                      let finddatas = datas.filter((item) => item.countitem == name[i]);
                      if (finddatas.length == 0) {
                          this.$refs.xTable2.insert({ countitem: name[i], countcode: code[i] }).then(({ row }) => {
                              this.$refs.xTable2.setCurrentRow(row);
                          });
                          this.currRowIndex = name.length - 1;
                      }
                      this[code[i]] = true;
                  }
              }
          }, 20);
      },
      SetFirst() {
          if (this.$refs.xTable2.getCurrentRow()) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(0, 0, currentrow);
              this.currentindex = 0;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetUp() {
          if (this.currentindex > 0) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(this.currentindex - 1, 0, currentrow);
              this.currentindex -= 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetDown() {
          if (this.currentindex >= 0 && this.currentindex < this.$refs.xTable2.tableData.length - 1) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.splice(this.currentindex + 1, 0, currentrow);
              this.currentindex += 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      SetLast() {
          if (this.$refs.xTable2.getCurrentRow()) {
              var currentrow = this.$refs.xTable2.getCurrentRow();
              this.$refs.xTable2.tableData = this.$refs.xTable2.tableData.filter((item) => item._XID != currentrow._XID);
              this.$refs.xTable2.tableData.push(currentrow);
              this.currentindex = this.$refs.xTable2.tableData.length - 1;
              this.$nextTick(() => {
                  this.$refs.xTable2.setCurrentRow(currentrow);
                  this.$refs.xTable2.scrollToRow(currentrow);
              });
          }
      },
      dialogcountItemsave() {
          let data = this.$refs.xTable2.tableData;
          let res1 = "";
          let res2 = "";
          if (data.length > 0) {
              data.forEach((element) => {
                  if (res2 == "") {
                      res2 = element.countitem;
                      res1 = element.countcode;
                  } else {
                      res2 += "," + element.countitem;
                      res1 += "," + element.countcode;
                  }
                  this.tableColumn.push({
                      field: element.countcode,
                      title: element.countitem,
                  });
              });
          }
          this.infoitem = res2;
          this.infocode = res1;
          this.dialogcountItem = false;
      },
      //重置统计项目
      resetStasticItem() {
          this.rp_reqtype = false;
          this.rp_specimen_code = false;
          this.rp_req_itemcode = false;
          this.rp_req_itemname = false;
          this.rp_item_price = false;
          this.rp_charge_flag = false;
          this.rp_req_dt = false;
          this.rp_req_groupid = false;
          this.rp_saleman = false;
          this.rp_sampled_username = false;
          this.rp_hospitalname = false;
          this.rp_deptname = false;
          this.rp_wardname = false;
          this.rp_doctorname = false;
          this.rp_labhospitalname = false;
          this.rp_labdeptname = false;
          this.rp_labgroupname = false;
          this.rp_rptunitname = false;
          this.rp_rechk_username = false;
          this.rp_pat_sexname = false;
          this.rp_pat_typecode = false;
          this.rp_pat = false;
          this.rp_pat_diag = false;
          this.rp_pat_diag_icd = false;
          this.rp_pat_id = false;
          this.rp_pat_no = false;
          this.rp_req_bedno = false;
          this.rp_sampleyear = false;
          this.rp_samplemonth = false;
          this.rp_sampleday = false;
          this.rp_emer_flag = false;
          this.staticitemData = [];
      },
      querymodChange(value) {
          if (value) {
              let modList = localStorage.getItem("rm_Qmod_LIS652");
              let tempOption = JSON.parse(modList);
              this.querymodOption = tempOption;
              this.querymod = value;
              let obj = localStorage.getItem("rm_Qmod_LIS652_" + value);
              let jsondata = JSON.parse(obj);

              this.datename = jsondata.datename;
              this.searchobj.datetype = jsondata.datetype;
              this.searchobj.strdate = jsondata.strdate;
              this.searchobj.enddate = jsondata.enddate;
              this.searchobj.pattype = jsondata.pattype;
              this.searchobj.rptunitid = jsondata.rptunitid;
              this.searchobj.labgroupid = jsondata.labgroupid;
              this.searchobj.emerflag = jsondata.emerflag;
              this.searchobj.median = jsondata.median;
              this.searchobj.median2 = jsondata.median2;
              this.searchobj.tatminutes = jsondata.tatminutes;
              this.searchobj.onlyouttime = jsondata.onlyouttime;
              this.searchobj.tattype = jsondata.tattype;
              this.searchobj.outminutes = jsondata.outminutes;
              this.searchobj.reqdeptno = jsondata.reqdeptno;
              this.searchobj.reqitemcode = jsondata.reqitemcode;
              this.searchobj.req_groupid = jsondata.req_groupid;
              this.searchobj.starttime = jsondata.starttime;
              this.searchobj.endtime = jsondata.endtime;
              this.searchobj.timetype = jsondata.timetype;
              this.searchobj.iseliminate = jsondata.iseliminate;
              this.infocode = jsondata.infocode;
              this.infoitem = jsondata.infoitem;
          }
      },
      btnSavequerymod() {
          let jsondate = {
              datename: this.datename,
              datetype: this.searchobj.datetype,
              strdate: this.searchobj.strdate,
              enddate: this.searchobj.enddate,
              pattype: this.searchobj.pattype,
              rptunitid: this.searchobj.rptunitid,
              labgroupid: this.searchobj.labgroupid,
              emerflag: this.searchobj.emerflag,
              median: this.searchobj.median,
              median2: this.searchobj.median2,
              tatminutes: this.searchobj.tatminutes,
              onlyouttime: this.searchobj.onlyouttime,
              tattype: this.searchobj.tattype,
              outminutes: this.searchobj.outminutes,
              reqdeptno: this.searchobj.reqdeptno,
              reqitemcode: this.searchobj.reqitemcode,
              req_groupid: this.searchobj.req_groupid,
              starttime: this.searchobj.starttime,
              endtime: this.searchobj.endtime,
              timetype: this.searchobj.timetype,
              iseliminate: this.searchobj.iseliminate,
              infocode: this.infocode,
              infoitem: this.infoitem,
          };
          this.$prompt("查询模版保存名称", "文字编辑", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
          })
              .then(({ value }) => {
                  if (value && value.trim() != "") {
                      this.querymodOption = [];
                      let modOption = localStorage.getItem("rm_Qmod_LIS652");
                      let modOptions = JSON.parse(modOption);
                      let item = undefined;
                      if (modOptions != null) {
                          this.querymodOption = XEUtils.clone(modOptions, true);
                          item = modOptions.find((m) => m.value == value);
                      }
                      if (item != undefined) {
                      } else {
                          this.querymodOption.push({ label: value, value: value });
                      }
                      let modListJson = JSON.stringify(jsondate);
                      let modList = JSON.stringify(this.querymodOption);
                      localStorage.setItem("rm_Qmod_LIS652_" + value, modListJson);
                      localStorage.setItem("rm_Qmod_LIS652", modList);
                      this.querymod = value;
                  }
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "取消输入",
                  });
              });
      },
      btnDelquerymod() {
          this.$confirm("您确定删除查询模版：" + this.querymod + "吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  let value = this.querymod;
                  localStorage.removeItem("rm_Qmod_LIS652_" + value);
                  let modList = localStorage.getItem("rm_Qmod_LIS652");
                  let jsondate = JSON.parse(modList);
                  this.querymodOption = [];
                  jsondate.forEach((item) => {
                      if (item.value == value) {
                      } else {
                          this.querymodOption.push(item);
                      }
                  });
                  let newmodList = JSON.stringify(this.querymodOption);
                  localStorage.setItem("rm_Qmod_LIS652", newmodList);
                  this.querymod = "";
              })
              .catch(() => {});
      },
      filterreqitem() {
          if (this.searchobj.rptunitid == "" || this.searchobj.rptunitid == null) {
              this.popMultipleChk(this.searchobj.reqitemcode, "reqitemcode", this.oReqitemOption, "请选择申请项目");
          } else {
              this.$tool
                  .request({
                      url: "LIS/LIS6/LIS652",
                      method: "post",
                      data: {
                          action: "filterreqitem",
                          rptunitids: this.searchobj.rptunitid,
                      },
                  })
                  .then((res) => {
                      //数据待后台返回
                      console.log(res);
                      if (res.flag == "1") {
                          this.reqitemOption = res.dt;
                          this.popMultipleChk(this.searchobj.reqitemcode, "reqitemcode", this.reqitemOption, "请选择申请项目");
                      } else {
                          this.popMultipleChk(this.searchobj.reqitemcode, "reqitemcode", this.oReqitemOption, "请选择申请项目");
                      }
                  })
                  .catch((e) => {
                      this.$alert(e, "出错");
                  });
          }
      },
      handleCommand(name) {
          this.datename = name;
          if (name == "接收日期") {
              this.searchobj.datetype = "recieve_dt";
          } else if (name == "报告日期") {
              this.searchobj.datetype = "report_dt";
          } else {
              this.searchobj.datetype = "recieve1_dt";
          }
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          if (value != "close") {
              this.searchobj[name] = value;
          }
          this.dialogMultipleVisible = false;
      },
      getLoginutype() {
          let loginutype = this.$tool.getSession(this.$tool.loginutype);
          if (loginutype == "G") {
              this.rptStyleSettingState = true;
          }
      },
      chkevent(e, code, name) {
          if (e == "1") {
              if (this.chkcnt <= 7) {
                  this.chkcnt++;
                  if (this.infocode.indexOf(code) == -1) {
                      this.infocode += code + ",";
                      this.infoitem += name + ",";
                  }
              } else {
                  this.$alert("不能选择更多的分组！", "提示");
                  this.chklist[code] = false;
              }
          } else {
              if (this.infocode.indexOf(code) > -1) {
                  this.chkcnt--;
                  this.infocode = this.infocode.replace(code, "");
                  this.infoitem = this.infoitem.replace(name, "");
              }
          }
      },
      getOption() {
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS652",
                  method: "post",
                  data: {
                      action: "getOptions",
                  },
              })
              .then((res) => {
                  //数据待后台返回
                  console.log(res);
                  this.reqitemOption = res.reqitemOption; //格式化时需要的全部的申请项目
                  this.oReqitemOption = res.reqitemOption;
                  this.reqgroupOption = res.reqgroupOption; //分单类别
              })
              .catch((e) => {
                  this.$alert(e, "出错");
              });
      },
      async initOption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS6/LIS652",
                  method: "post",
                  data: {
                      action: "initoption",
                  },
              });
              this.pattypeOption = res.pattypeOption;
              this.deptOption = res.deptOption;
              this.hospOption = res.hospOption;
              this.doctorOption = res.doctorOption;
              this.rptunitOption = res.rptunitOption;
              this.rptunitGroupOption = res.rptunitGroupOption;
              this.wardOption = res.wardOption;
              this.labgroupOption = res.labgroupOption;
              this.specimenOption = res.specimenOption;
              this.userOption = res.userOption;
              this.querymodOption = [];
              let modOption1 = localStorage.getItem("rm_Qmod_LIS652");
              let modOptions1 = JSON.parse(modOption1);
              if (modOptions1 != null) {
                  this.querymodOption = XEUtils.clone(modOptions1, true);
              }
          } catch (e) {
              this.$message.warning(e);
          }
      },
      BtnQuery() {
          this.InitPage();
      },
      BtnSort() {
          this.$rmsort(
              { tableColumn: this.SortTableColumn, sortArr: this.sortArr },
              {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
              }
          )
              .then((res) => {
                  this.sortArr = res.data;
                  this.InitPage();
              })
              .catch(() => {});
      },
      BtnClear() {
          this.searchobj = {
              strdate: this.$pub.InitDateTime(),
              enddate: this.$pub.InitDateTime(),
              pattype: "",
              rptunitid: "",
              labgroupid: "",
              emerflag: "",
              median: "50",
              median2: "90",
              tatminutes: "",
              tattype: "RP",
              outminutes: "",
              reqdeptno: "",
              reqitemcode: "",
              req_groupid: "",
          };
          this.tableData = [];
          this.staticitemData = [];
          this.infocode = "";
          this.infoitem = "";
          // this.chklist = {
          //     rp_pat_typecode: false,
          //     rp_req_deptno: false,
          //     rp_req_groupid: false,
          //     rp_sample_items: false,
          //     rp_labgroupname: false,
          //     rp_specimen_code: false,
          //     rp_emer_flag: false,
          //     rp_sampleyear: false,
          //     rp_samplemonth: false,
          //     rp_sampleday: false,
          // };
      },
      BtnExport(type) {
          let exportColumn = [];
          let tableColumn = this.$refs.xTable.getColumns();
          tableColumn.forEach((item) => {
              exportColumn.push({ title: item.title, field: item.property });
          });
          let filtertxt = this.getExportFilter();
          this.$pub.exportTableExcel(this.tableData, exportColumn, "LIS652_TAT合格率统计(按申请).xlsx", filtertxt, "统计条件：");
      },
      BtnPrint(index) {
          // let columnArr = [
          //     { title: "细菌名称", property: "细菌名称" },
          //     { title: "细菌次数", property: "细菌次数" },
          //     { title: "细菌金额", property: "细菌金额" },
          //     { title: "药敏项次", property: "药敏项次" },
          //     { title: "药敏金额", property: "药敏金额" },
          //     { title: "合计金额", property: "合计金额" },
          // ];
          // columnArr.push({ title: "检验日期", property: "chkdate" });
          // columnArr.push({ title: "单元", property: "rptunitname" });
          // let str = JSON.stringify(columnArr);
          // str += "\r";
          // str += JSON.stringify(this.$refs.xTable.afterFullData);
          // let sql = btoa(encodeURIComponent(str));
          // if (index == "1") {
          //     jsObj.PrintCustomJsonReport("5033", sql, this.userno, "细菌工作量统计", "");
          // } else {
          //     jsObj.SetCustomJsonPrintConfig("5033", sql, this.userno, "细菌工作量统计");
          // }
      },
      rCellDblClick({ row, column }) {
          this.unquaildata = [];
          this.selrow = row;
          if (row.unquailcnt == "0") {
              this.$message.info("无不合格标本！");
              return false;
          }

          this.bunquaildlg = true;
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS652",
                  method: "post",
                  data: {
                      action: "queryDetail",
                      sqlstr: row.sqlstr,
                  },
              })
              .then((res) => {
                  if (res && res != "" && res.length > 0) {
                      this.unquaildata = res;
                  }
              })
              .catch((e) => {});
      },
      InitPage() {
          if (this.infocode == "") {
              this.$alert("请选择统计项目!");
              return false;
          }
          if (this.searchobj.onlyouttime == "1") {
              if (!this.searchobj.tatminutes) {
                  this.$refs.reftatminutes.focus();
                  this.$pub.message(this, "请先输入基准时间！", "warning");
                  return false;
              }
          }
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS6/LIS652",
                  method: "post",
                  timeout: 6000000,
                  data: {
                      action: "InitPage",
                      sortArr: this.sortArr, //排序
                      infocode: this.infocode,
                      infoitem: this.infoitem,
                      ...this.searchobj,
                  },
              })
              .then((response) => {
                  let filedArr = this.infocode.split(",");
                  let titleArr = this.infoitem.split(",");
                  this.tableColumn = [];
                  for (let index = 0; index < filedArr.length; index++) {
                      const title = titleArr[index];
                      const field = filedArr[index];
                      if (field != "") {
                          let width = "80px";
                          let align = "left";
                          if (["rp_sampleyear", "rp_samplemonth", "rp_pat_typecode", "rp_emer_flag"].includes(field)) width = "60px";
                          else if (["rp_req_deptno", "rp_labgroupname"].includes(field)) width = "120px";
                          else if (field == "rp_sample_items") width = "160px";
                          if (["rp_sampleyear", "rp_samplemonth", "rp_sampleday", "rp_pat_typecode", "rp_emer_flag"].includes(field)) align = "center";
                          if (["rp_req_itemcode"].includes(field)) {
                              width = "120px";
                              this.tableColumn.push({ title: "申请项目名称", field: "rp_req_itemname", width: "200", align: "left" });
                          }
                          this.tableColumn.push({ title: title, field: field, width: width, align: align });
                      }
                  }
                  if (response.errcode == "1") {
                      this.loading = false;
                      this.tableData = response.Data;
                      this.xTableKey++;
                  } else {
                      this.$alert(response.errmsg, "信息");
                      this.loading = false;
                  }
              })
              .catch((e) => {
                  this.loading = false;
                  this.$message.warning(e);
              });
      },
      footerCellClassName({ $rowIndex, column, columnIndex }) {
          if (columnIndex === 0 || ["samplecnt", "untatcnt", "minminutes", "maxminutes", "avgminutes", "median", "median2", "tatminutes", "unquailcnt", "quailcnt", "passrate"].includes(column.property)) {
              if ($rowIndex === 0) {
                  return "col-blue";
              } else {
                  return "col-red";
              }
          }
      },
      footerMethod({ columns, data }) {
          return [
              columns.map((column, columnIndex) => {
                  if (columnIndex === 0) {
                      return "统计";
                  }
                  if (["samplecnt", "untatcnt", "unquailcnt", "quailcnt"].includes(column.property)) {
                      return XEUtils.sum(data, column.property);
                  } else if (["minminutes", "maxminutes", "avgminutes", "median", "median2", "tatminutes"].includes(column.property)) {
                      return XEUtils.mean(data, column.property).toFixed(2);
                  } else if (column.property == "passrate") {
                      if (XEUtils.sum(data, "samplecnt") == 0) {
                          return 0;
                      } else {
                          return ((XEUtils.sum(data, "quailcnt") / XEUtils.sum(data, "samplecnt")) * 100).toFixed(2);
                      }
                  }
                  return null;
              }),
          ];
      },
      rptunitchange(code, name) {
          this.searchobj.rptunitid = code;
          this.rptunitname = name;
      },
      selectBlur(vcode, refcode, list) {
          let query = this.$refs[refcode].selectedLabel;
          var re = /^[0-9]+.?[0-9]*$/;
          if (!re.test(query)) {
              //不是数字,暂时不做任何事
              if (query.indexOf("[") == -1) {
                  //如果是输入值，此时没有光标选中传空值，如果是光标选中的选项不用处理自动传递
                  // this.$emit("change", "", "");
              }
          } else {
              //是数字
              if (query !== "") {
                  //let list = list.find((m) => m.data == query);
                  if (["refrptunitid", "reflabgroupid"].includes(refcode)) {
                      this.searchobj[vcode] = Number(query);
                  } else {
                      this.searchobj[vcode] = query;
                  }
                  this.$refs[refcode].blur();
              }
          }
      },
      formatFun({ cellValue, column }) {
          if (["rp_req_deptno", "req_deptno"].includes(column.property)) {
              try {
                  let deptname = this.deptOption.find((m) => m.data == cellValue);
                  if (deptname != undefined && deptname != null) {
                      return deptname.display;
                  } else {
                      return cellValue;
                  }
              } catch {}
          } else if (column.property == "rp_pat_typecode") {
              try {
                  let pattypename = this.pattypeOption.find((m) => m.data == cellValue);
                  if (pattypename != undefined && pattypename != null) {
                      return pattypename.display;
                  } else {
                      return cellValue;
                  }
              } catch {}
          } else if (column.property == "rp_specimen_code") {
              try {
                  let specimenname = this.specimenOption.find((m) => m.data == cellValue);
                  if (specimenname != undefined && specimenname != null) {
                      return specimenname.display;
                  } else {
                      return cellValue;
                  }
              } catch {
                  return cellValue;
              }
          } else if (column.property == "rp_emer_flag") {
              if (cellValue == "1") {
                  return "加急";
              } else {
                  return "常规";
              }
          } else if (column.property == "rp_labgroupname") {
              try {
                  let labgroup = this.labgroupOption.find((m) => m.data == cellValue);
                  if (labgroup != undefined && labgroup != null) {
                      return labgroup.display;
                  } else {
                      return cellValue;
                  }
              } catch {
                  return cellValue;
              }
          } else if (column.property == "rp_req_groupid") {
              try {
                  let reqgroup = this.reqgroupOption.find((m) => m.data == cellValue);
                  if (reqgroup != undefined && reqgroup != null) {
                      return reqgroup.display;
                  } else {
                      return cellValue;
                  }
              } catch {
                  return cellValue;
              }
          } else if (column.property == "passrate") {
              return Number(cellValue).toFixed(2);
          } else {
              return cellValue;
          }
      },
      querySearch(queryString, cb) {
          cb(this.tatminutesOption);
      },
      ExportResult() {
          let data = this.getExportData();
          let filtertxt = "统计条件：" + this.getExportFilter();
          var systemtime = XEUtils.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss");
          let currowinfo = this.getCurrowInfo();
          this.$pub.exportTableExcelWithData(data, this.exportTableColLen, "LIS652_TAT合格率统计(按申请)_" + systemtime + ".xlsx", filtertxt, "当前不合格标本统计项目条件：" + currowinfo);
      },
      getCurrowInfo() {
          let infostr = "";
          if (this.infocode) {
              let codelist = this.infocode.split(",");
              let namelist = this.infoitem.split(",");
              for (let i = 0; i < codelist.length; i++) {
                  if (this.selrow[codelist[i]]) {
                      infostr += namelist[i] + ":" + this.formatFun({ cellValue: this.selrow[codelist[i]], column: { property: codelist[i] } }) + "; ";
                  }
              }
          }
          return infostr;
      },
      // 获取当前导出文件的所有查询条件
      getExportFilter() {
          let filtertxt = this.datename + ":" + XEUtils.toDateString(this.searchobj.strdate, "yyyy-MM-dd") + "至" + XEUtils.toDateString(this.searchobj.enddate, "yyyy-MM-dd") + "; ";
          if (this.searchobj.pattype) filtertxt += "病人类型:" + this.getOptionName(this.pattypeOption.filter((item) => ("," + this.searchobj.pattype + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.searchobj.labgroupid) filtertxt += "检验组别:" + this.getOptionName(this.labgroupOption.filter((item) => this.searchobj.labgroupid == item.data)) + "; ";
          if (this.searchobj.reqdeptno) filtertxt += "申请科室:" + this.getOptionName(this.deptOption.filter((item) => ("," + this.searchobj.reqdeptno + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.searchobj.emerflag) filtertxt += "急诊标志:" + (this.searchobj.emerflag == "1" ? "急诊" : "常规") + "; ";
          if (this.searchobj.req_groupid) filtertxt += "分单类别:" + this.getOptionName(this.reqgroupOption.filter((item) => ("," + this.searchobj.req_groupid + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.searchobj.rptunitid) filtertxt += "报告单元:" + this.getOptionName(this.rptunitOption.filter((item) => ("," + this.searchobj.rptunitid + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.searchobj.median) filtertxt += "分位数基准:" + this.searchobj.median + "; ";
          if (this.searchobj.median2) filtertxt += "基准2:" + this.searchobj.median2 + "; ";
          if (this.searchobj.tatminutes) filtertxt += "基准时间:" + this.searchobj.tatminutes + "; ";
          if (this.searchobj.onlyouttime == "1") filtertxt += "仅统计超出基准时间; ";
          if (this.searchobj.outminutes) filtertxt += "大于" + this.searchobj.outminutes + "分钟不统计; ";
          if (this.querymod) filtertxt += "查询模版:" + this.getOptionName(this.querymodOption.filter((item) => this.querymod == item.value)) + "; ";
          if (this.searchobj.reqitemcode) filtertxt += "申请项目:" + this.getOptionName(this.reqitemOption.filter((item) => ("," + this.searchobj.reqitemcode + ",").indexOf("," + item.data + ",") > -1)) + "; ";
          if (this.searchobj.tattype) filtertxt += "统计类型:" + this.getOptionName(this.stattypeOption.filter((item) => this.searchobj.tattype == item.data)) + "; ";
          let timetxt = "";
          if (this.searchobj.starttime) timetxt += this.searchobj.starttime;
          if (this.searchobj.endtime) timetxt += "至" + this.searchobj.endtime;
          if (this.searchobj.starttime || this.searchobj.endtime) filtertxt += this.getTimeName() + ":" + timetxt + "; ";
          if (this.infocode) filtertxt += "统计项目:" + this.infoitem + "; ";
          return filtertxt;
      },
      getTimeName() {
          let name = "";
          let iselname = this.searchobj.iseliminate == "1" ? "剔除" : "";
          switch (this.searchobj.timetype) {
              case "recieve":
                  name = "接收时间";
                  break;
              case "report":
                  name = "报告时间";
                  break;
              case "recieve1":
                  name = "签收时间";
                  break;
          }
          return iselname + name;
      },
      getOptionName(option) {
          if (option && option.length > 0) {
              let optionname = "";
              option.forEach((item) => {
                  if (item.hasOwnProperty("display")) {
                      optionname += item.display + ",";
                  } else {
                      optionname += item.label + ",";
                  }
              });
              return optionname.substring(0, optionname.length - 1);
          } else {
              return "";
          }
      },
      getExportData() {
          let datas = this.unquaildata;
          var allcolumns = this.$refs.reqtable.getColumns();
          var tableColumn = [];
          for (let i = 0; i < allcolumns.length; i++) {
              tableColumn.push({
                  field: allcolumns[i].property,
                  title: allcolumns[i].title,
              });
          }
          this.exportTableColLen = tableColumn.length;
          let columns = tableColumn.filter((item) => item.field);
          let headers = [columns.map((item) => item.title)];
          return headers.concat(
              datas.map((row) => {
                  return columns.map((column) => {
                      return row[column.field];
                  });
              })
          );
      },
  },
};
</script>

<style scoped>
.pagetop {
  left: 0;
  right: 0;
  width: 100%;
  height: 135px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
  overflow-x: auto;
  overflow-x: overlay;
}
.pagecenter {
  position: absolute;
  top: 140px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}
.el-checkbox__label {
  padding: 0px;
}
.left_nav {
  width: 20%;
  height: 100%;
  border-right: 1px solid #ccc;
  padding: 0px 0px 0px 0px;
  float: left;
  display: inline;
}
.left_nav div {
  cursor: pointer;
  height: 40px;
  width: 100%;
  float: left;
  padding-left: 20px;
  line-height: 40px;
}
.left_nav .active {
  background-color: DeepSkyBlue;
}
.right_nav {
  width: 80%;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  float: left;
  display: inline;
}
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}
.table1style tr td {
  padding: 0px 2px 0px 5px;
}
.top-btn {
  background-color: #e6e6e6;
  color: black;
  margin-left: 3px;
}
::v-deep .mytable-style .vxe-footer--column.col-blue {
  color: blue !important;
  font-weight: bold;
}
::v-deep .mytable-style .vxe-body--row.row-blue {
  color: blue !important;
  font-weight: bold;
}
::v-deep .el-checkbox__label {
  padding-left: 0px;
}

::v-deep .el-icon-time {
  line-height: 18px !important;
}
::v-deep .el-range__close-icon {
  line-height: 18px !important;
}
::v-deep .el-range-editor--small .el-range-separator {
  line-height: 17px !important;
}
::v-deep .chktable tr td {
  padding-left: 20px;
}
::-webkit-scrollbar {
  width: 0px;
  height: 5px;
  border: 4px solid white;
}
::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
}
::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}
/* Buttons */
::-webkit-scrollbar-button:single-button {
  background-color: #bbbbbb;
  display: block;
  border-style: solid;
  height: 5px;
  width: 5px;
}
/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
  margin-right: 2px;
  border-width: 4px 4px 4px 0;
  border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:decrement:hover {
  border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}
/* Right */
::-webkit-scrollbar-button:horizontal:increment {
  margin-left: 2px;
  border-width: 4px 0 4px 4px;
  border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
  background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:increment:hover {
  border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}
</style>